From 04c630d0fd713a683e6a1eb8f3bd7fb9c70a2b1d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 5 Oct 2010 23:22:25 +0200 Subject: [PATCH] viewport: Clip contents properly when called via gtk_widget_draw() --- gtk/gtkviewport.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index 7f24b54ace..5988682330 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -784,6 +784,21 @@ gtk_viewport_draw (GtkWidget *widget, gdk_window_get_height (gtk_widget_get_window (widget))); } + if (gtk_cairo_should_draw_window (cr, priv->view_window)) + { + /* This is a cute hack to ensure the contents of bin_window are + * restricted to where they are visible. We only need to do this + * clipping when called via gtk_widget_draw() and not in expose + * events. And when that happens every window (including this one) + * should be drawn. + */ + gdk_window_get_position (priv->view_window, &x, &y); + cairo_rectangle (cr, x, y, + gdk_window_get_width (priv->view_window), + gdk_window_get_height (priv->view_window)); + cairo_clip (cr); + } + if (gtk_cairo_should_draw_window (cr, priv->bin_window)) { gdk_window_get_position (priv->bin_window, &x, &y); -- 2.30.2